package mk.com.ldm.corepoint.administration.client.view;

import mk.com.ldm.corepoint.administration.client.presenter.LoginPresenter;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class LoginView extends Composite implements LoginPresenter.Display {
	
  private final Label userLabel;
  private final TextBox userTextBox;
  private final Label passLabel;
  private final PasswordTextBox passTextBox;
  private final Button loginButton;
  private FlexTable contentTable;
  
  
  public LoginView() {
    FlexTable wrapper = new FlexTable();
    initWidget(wrapper);
    wrapper.setWidth("100%");
    wrapper.setWidth("18em");
    wrapper.setStyleName("center");

    contentTable = new FlexTable();
    contentTable.setWidth("100%");
    
    userLabel = new Label("Username:");
    userTextBox = new TextBox();
    passLabel = new Label("Password:");
    passTextBox = new PasswordTextBox();
    loginButton = new Button("Login");
    Label logo = new Label("CorePoint Administration");
    logo.setStyleName("logo");
   
    contentTable.setWidget(0, 0, logo);
    contentTable.setWidget(1, 0, userLabel);
    contentTable.setWidget(1, 1, userTextBox);
    contentTable.setWidget(2, 0, passLabel);
    contentTable.setWidget(2, 1, passTextBox);
    contentTable.setWidget(3, 0, loginButton);
    
    contentTable.getFlexCellFormatter().setColSpan(0, 0, 2);
    contentTable.getFlexCellFormatter().setColSpan(3, 0, 2);
    contentTable.setStyleName("loginForm");
    
    DecoratorPanel content = new DecoratorPanel();
    content.add(contentTable);
    
    
    wrapper.setWidget(0, 0, content);
  }
  
  
  
  public Widget asWidget() {
    return this;
  }




  public Button getLoginButton() {
	  // TODO Auto-generated method stub
	  return loginButton;
  }




  public TextBox getUsername() {
	// TODO Auto-generated method stub
	  return userTextBox;
  }



@Override
public PasswordTextBox getPassword() {
	// TODO Auto-generated method stub
	return passTextBox;
}

public FlexTable getContentTable(){
	return contentTable;
}
}
